<?php
/**
 * 缓存目录位置
 */
FLEA::setAppInf('internalCacheDir', ROOT_DIR . '/cache/runtime');

/**
 * 数据库配置文件
 */
$database = require 'database.php';

/**
 * 环境配置文件
 */
$environment = require 'environment.php';

/**
 * 模式配置文件
 */
$deploy = defined('DEPLOY_MODE') && DEPLOY_MODE;
if ( $deploy ) {
	$lifetime = 86400; //一天
    $mode = require 'deploy.php';
} else {
	$lifetime = 0;
	$mode = require 'devel.php';
}

/**
 * 返回配置
 */
$cacheid = 'config.' . ($this->_app ? $this->_app . '.' : '') . ($deploy ? 'deploy' : 'development');
$_config = FLEA::getCache($cacheid, $lifetime, true, true);
if (is_array($_config)) { return $_config; }

$_config = array_merge( $database , $environment , $mode );
FLEA::writeCache($cacheid, $_config, true);
return array_merge( $database , $environment , $mode );
